package com.ekalenchuk.module.service.secutiry;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import com.ekalenchuk.module.dto.session.UserSession;

public class CustomLogoutHandler implements LogoutHandler {

	public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
		UserSession userSession = (UserSession)authentication.getDetails();
		if(userSession != null) {
			userSession.destroy();
		}
	}

}
